import React from 'react';
import { Button, Modal, Form, Input, Radio } from 'antd';
import { injectIntl } from 'react-intl';
import DepartmentPicker from '../../components/pickCity/departmentPicker';

const FormItem = Form.Item;
const createForm = Form.create;
class modifyCarForm extends React.Component {

    // validatePhone=(rule, value, callback)=>{
    //     let myreg=/^1[3|4|5|7|8][0-9]{9}$/;
    //     if (value&&!myreg.test(value)) {
    //         callback('请输入正确手机号');
    //     } else {
    //         callback();
    //     }
    // }
    // validateAcccount=(rule, value, callback)=>{
    //     let myreg=/^1[3|4|5|7|8][0-9]{9}$/;
    //     if (value&&!myreg.test(value)) {
    //         callback('用户名必须为手机格式');
    //     } else {
    //         callback();
    //     }
    // }

    render() {
        const common = this.props.intl.messages.common;
        const { visible, onCancel,onCreate, form } = this.props;
        const { getFieldDecorator } = form;
        return (
            <Modal
                visible={visible}
                title={common.modifyInfo}
                okText={common.sure}
                onCancel={onCancel}
                onOk={onCreate}
            >
                <Form layout="vertical">
                    <FormItem label={common.carNO}>
                        {getFieldDecorator('plateNo', {
                            rules: [{
                                required: true, message: `${common.carNONotEmpty}!`,
                            }],
                            initialValue:this.props.selectedInfo.plateNo
                        })(
                            <Input />
                        )}
                    </FormItem>
                    <FormItem label={common.VIN}>
                        {getFieldDecorator('vin',{
                            rules: [
                                {
                                required: true, message: `${common.VINNotEmpty}!`,
                                },
                                {
                                    max:17,message: `${common.VINMust17}!`,
                                },
                                {
                                    min:17,message: `${common.VINMust17}!`,
                                },
                                // // {
                                // //     type:'number',message: common.VINMustNumber,transform(value) {
                                // //         return Number(value);
                                // //     }
                                // }
                            ],
                            initialValue:this.props.selectedInfo.vin
                        })(
                            <Input />
                        )}
                    </FormItem>
                    <FormItem label={'所属部门'}>
                        {getFieldDecorator('org', {
                            initialValue:this.props.selectedInfo.org
                        })(
                            <DepartmentPicker />
                        )}
                    </FormItem>
                    <FormItem label={'自编码'}
                    >
                        {getFieldDecorator('num',{
                            initialValue:this.props.selectedInfo.num
                        })(
                            <Input placeholder="自编码"/>
                        )}
                    </FormItem>
                </Form>
            </Modal>
        );
    }
}

modifyCarForm=createForm()(modifyCarForm);
export default injectIntl(modifyCarForm);